package dongshi.daddy.controller;

import dongshi.daddy.pojo.Order;
import dongshi.daddy.service.OrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.stream.IntStream;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    private OrderService orderService;

    @PostMapping("/addOrder")
    public Order addUser() {
        long timeMillis = System.currentTimeMillis();
        IntStream.rangeClosed(1, 10).forEach(value -> {
            Order order = new Order();
            order.setOrderId(timeMillis + value);
            order.setName("张三" + value);
            orderService.insertOder(order);
        });
        return new Order();
    }

    @PostMapping("/delOrder")
    public String delOrder() {
        orderService.deleteAllInBatch();
        return "OK";
    }

}
